package com.znf4.timer;
/*ackage com.znf4.platform.timer;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.znf4.platform.account.enums.AccountFundDirectionEnum;
import com.znf4.platform.account.service.RpAccountTransactionService;
import com.znf4.platform.account.vo.AccountTransactionVo;
import com.znf4.platform.common.core.utils.BigDecimalUtil;
import com.znf4.platform.common.core.utils.DateUtils;
import com.znf4.platform.common.core.utils.StringUtil;
import com.znf4.platform.trade.enums.TrxTypeEnum;
import com.znf4.platform.user.entity.RpUserInfo;
import com.znf4.platform.user.service.RpUserInfoService;

*//**
 * 微信商户分润定时器
 *//*
public class FenRunMerchantTimer {
	private static final Logger LOG = LoggerFactory.getLogger(FenRunMerchantTimer.class);

	@Resource
	private RpUserInfoService rpUserInfoService;
	@Resource
	private RpAccountTransactionService rpAccountTransactionService;

	// 执行方法
	public void run() {
		LOG.info("开始分润");
		//查找所有用户
		List<RpUserInfo> userInfos = rpUserInfoService.listAll();
		LOG.info("用户数量：{}",userInfos.size());
		List<AccountTransactionVo> accountTransactionVos = new ArrayList<AccountTransactionVo>();//所有要处理分润的数据
		
		for (RpUserInfo rpUserInfo : userInfos) {
			Map<String, Object> resultMap = rpUserInfoService.getMyThreeLevelMerchantByUserNo(rpUserInfo.getUserNo());
			if (StringUtil.isNotNull(resultMap)) {
				LOG.info("用户存在");
				String level1 = (String) resultMap.get("level1OrderAmount");
				String level2 = (String) resultMap.get("level2OrderAmount");
				String level3 = (String) resultMap.get("level3OrderAmount");
				int level1Count = (int) resultMap.get("level1Count");//
				BigDecimal l1 = new BigDecimal(Double.valueOf(level1));
				BigDecimal l2 = new BigDecimal(Double.valueOf(level2));
				BigDecimal l3 = new BigDecimal(Double.valueOf(level3));
				BigDecimal level1Fee = BigDecimalUtil.multiply(new BigDecimal(Double.valueOf("0.00003")), l1);
				BigDecimal level2Fee = BigDecimalUtil.multiply(new BigDecimal(Double.valueOf("0.00002")), l2);
				BigDecimal level3Fee = BigDecimalUtil.multiply(new BigDecimal(Double.valueOf("0.00001")), l3);
				//计算三级每日交易总量
				BigDecimal sum = BigDecimalUtil.add(level1Fee, level2Fee); // 1 2   总和
				BigDecimal sumFee = BigDecimalUtil.add(sum, level3Fee);    // 1 2 3 总和
			
				AccountTransactionVo accountTransactionVo = new AccountTransactionVo();

				accountTransactionVo.setUserNo(rpUserInfo.getUserNo());
				accountTransactionVo.setAccountFundDirection(AccountFundDirectionEnum.ADD);
				// 特定代付通道--易联
				accountTransactionVo.setBankChannelCode("QUICK_PAY_YI_LIAN_T0");
				accountTransactionVo.setBankChannelName("QUICK_PAY_YI_LIAN_T0");
				//构造分润编号
				StringBuffer no = new StringBuffer("FR");
				no.append(DateUtils.getReqDateyyyyMMdd(new Date()));
				no.append(rpUserInfo.getAccountNo());

				accountTransactionVo.setBankTrxNo(no.toString());
				accountTransactionVo.setCompleteTime(new Date());
				accountTransactionVo.setDesc("用户分润");
				accountTransactionVo.setPayWayCode("QUICKPAY");

				accountTransactionVo.setRequestNo(no.toString());
				accountTransactionVo.setSettType("T0");
				accountTransactionVo.setTrxType(TrxTypeEnum.EXPENSE_PROFIT);
				accountTransactionVo.setAmount(sumFee);
				if (level1Count >= 3) {
					LOG.info("用户推荐数量>3：{}",rpUserInfo.getUserNo());
					String merchantOrderAmount = (String) resultMap.get("merchantOrderAmount");// 商户订单
					BigDecimal amount = new BigDecimal(Double.valueOf(merchantOrderAmount));
					BigDecimal amountFree = BigDecimalUtil.multiply(new BigDecimal(Double.valueOf("0.00001")), amount);
					BigDecimal total = BigDecimalUtil.add(sumFee, amountFree);// 最后合计金额

					accountTransactionVo.setAmount(total);//重新设置分润值
				} 
				accountTransactionVos.add(accountTransactionVo);

			}
			
			rpAccountTransactionService.batchExecute(accountTransactionVos);
		}
	}

}
*/